﻿@model Catalog
@Html.Extra()
@{
    Layout = "~/Views/Shared/OA/_Edit.cshtml";
}
@section Toolbar
{
    @Html.MyNet().Button(new ButtonOptions { Text = "保存", Click = "save" })
    @Html.MyNet().Button(new ButtonOptions { Text = "返回", Click = "back" })
}
@section Main
{
    @Html.HiddenFor(model => model.Id)
    @Html.HiddenFor(model => model.Config)
    @switch ((CatalogType)Model.Type)
    {
        case CatalogType.Article:
        case CatalogType.Topic:
            @Html.Partial("_ConfigForArticle")
            break;
        case CatalogType.ArticleDetail:
            @Html.Partial("_ConfigForArticle")
            break;
        case CatalogType.Image:
            @Html.Partial("_ConfigForImage")
            break;
        case CatalogType.Advertisement:
            @Html.Partial("_ConfigForAdvertisement")
            break;
        case CatalogType.FriendshipLink:
            @Html.Partial("_ConfigForFriendshipLink")
            break;
        case CatalogType.QPH:
            @Html.Partial("_ConfigForQPH")
            break;
        case CatalogType.Other:
            break;
        default:
            break;
    }
}
<style>
    .form label { margin-right: 5px; }
    .form .k-textbox { width: 200px; margin-right: 5px; }
    .k-numerictextbox { margin-right: 5px; }
</style>
<script>

    function save() {
        var form = $("form");
        if (!form.valid()) return;

        $.ajax
            ({
                url: form.attr("action"),
                data: form.serialize(),
                type: "post",
                error: disposeError,
                success: function (result) {
                    if (disposeException(result)) return;
                    var data = { id: result.Id, text: result.Name, parentId: result.ParentId };
                    back(true, data);
                }
            });
    }

</script>
